<!DOCTYPE html>
<html lang="en">

<head>
    <link rel="stylesheet" type="text/css" href="index.css">
    <meta charset="UTF-8">
    <title>聊天记录</title>
    <style type="text/css">
        body {
            max-width: 100xw;
            max-height: 100vh;
            padding: 10px;
        }

        li {
            list-style-type: none;
            /* 去掉li前的点 */
            float: left;
            /*将li设置成做浮动，变为联动*/
        }

        a {
            display: block;
            /*将a变成块状*/
            width: 30vw;
            /*设置块的宽度*/
            height: 50px;
            /*设置块的长度*/
            font-family: Microsoft Yahei;
            line-height: 50px;
            /*设置字体在块中的高度*/
            background-color: #66B3FF;
            margin: 0px 0px;
            /*块里的高宽通过margin设置*/
            color: #fff;
            text-align: center;
            /*字体居中*/
            text-decoration: none;
            /*去掉下划线*/
            font-size: 15px;
            border: 5px;
            border-radius: 2px;
            border-color: black;
        }

        a:hover {
            background-color: #84C1FF;
        }

        .chat-content {
            background-color: white;
            width: 90vw;
            height: 100vh;
            padding: 20px;
            border-radius: 10px;
            line-height: 40px;
            /* overflow-y: scroll; */
        }

        .friend-name {
            text-align: center;
            margin-top: 30px;
        }

        .my-content {
            justify-content: flex-end;
            margin-top: 10px;
        }

        .my-text {
            background-color: aqua;
            border-radius: 7px;
            padding: 7px;
            height: 50px;
            margin-top: 10px;
        }

        .other-content {

            margin-top: 10px;
        }

        .other-text {
            background-color: aquamarine;
            border-radius: 7px;
            padding: 7px;
            height: 50px;
            margin-top: 10px;
        }

        .my-name {
            margin-top: 0px;
            margin-left: 10px;
            font-weight: 600;
        }

        .other-name {
            margin-top: 0px;
            margin-right: 10px;
            font-weight: 600;
        }

        .text-section {
            height: 80vh;
            overflow-y: scroll;
        }

        .send-section {
            position: fixed;
            left: 150px;
            bottom: 10px;
            padding: 10px;
            display: flex;
            align-items: center;
        }

        .input-area {
            width: 70vw;
        }

        .send-button {
            width: 10vw;
            margin-left: 10px;
        }

        .bot1 {
            margin-top: 25px;
            margin-left: 45px;
            width: 10vw;
            height: 5vh;
            background-color: aquamarine;
            color: honeydew;
            border-radius: 5px;
            border-color: powderblue;
            font-family: Arial, Helvetica, sans-serif;
            font-size: large;
            opacity: 1;
        }
    </style>
</head>

<body>
    <div>
        <ul>
            <li><a href="" th:href="@{/market/index}" >物品展示</a></li>
            <li><a href="" th:href="@{/market/chat}">消息记录</a></li>
            <li><a href="" th:href="@{/market/my}">我的咸鱼</a></li>
        </ul>
    </div>
    <div>
        <form>
            <a class="bot1" style="background-color:#66B3FF;display:inline;font-size: x-large;font-weight: bolder;color: white;" th:href="@{/market/product/info(product_id=${product_id})}">返回商品详情页</a>
            <h2 class="friend-name">聊天记录</h2>
        </form>
    </div>
    <div class="chatroom">
        <div class="chat-content">

            <div class="text-section" style="display: flex;justify-content: space-between;">
                <div class="other-content">
                    <div style="display: flex;" th:each="to:${tos}"><!--在这个位置加th:each遍历，传入other-text里-->
                        <div class="other-name" th:text="${to.time}">XX用户</div>
                        <div class="other-text" th:text="${to.chatText}">你好</div>
                    </div>
                </div>
                <div class="my-content">
                    <div style="display: flex;" th:each="from:${froms}"><!--在这个位置加th:each遍历，传入my-text里-->
                        <div class="my-name" th:text="${from.time}">name</div>
                        <div class="my-text" th:text="${from.chatText}">..</div>
                    </div>
                </div>

                <div class="send-section">
                    <form  method="post" th:action="@{/market/chat/to(product_id=${product_id},to_id=${to_id})}">
                    <input type="text" class="input-area" id="send-content" name="chat_text">
                    <button class="send-button" type="submit">发送</button>
                    </form>
                </div>

            </div>
        </div>
    </div>
</body>

</html>